﻿using AutoMapper;
using Core.SimpleTemp.Common.PagingQuery;
using Core.Toolkit.Core.Entitys;
using Core.Toolkit.Core.Repositories.Internal;
using Core.Toolkit.PagingQuery;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;

namespace Core.Toolkit.Core.Application
{
    public static class BaseAppServiceExtension
    {
        #region 辅助方法
        public static LoadPageOffsetModel<TEntity, TDto> GetLoadPageOffsetModel<TDto, TEntity, TRepository, TDBContext>(this BaseAppService<TDto, TEntity, TRepository, TDBContext> baseAppService) where TEntity : Entity, new() where TRepository : BaseDBRepository<TDBContext, TEntity> where TDBContext : DbContext where TDto : Dto
            => new LoadPageOffsetModel<TEntity, TDto>();

        public static LoadPageOffsetModel<TEntity, TDto> GetLoadPageOffsetModel<TDto, TEntity, TRepository, TDBContext>(this BaseAppService<TDto, TEntity, TRepository, TDBContext> baseAppService, PagingModel<TDto> pagingQueryModel) where TEntity : Entity, new() where TRepository : BaseDBRepository<TDBContext, TEntity> where TDBContext : DbContext where TDto : Dto
             => Mapper.Map<LoadPageOffsetModel<TEntity, TDto>>(pagingQueryModel);

        public static LoadPageOffsetModelAuto<TEntity, TDto> GetLoadPageOffsetModelAuto<TDto, TEntity, TRepository, TDBContext>(this BaseAppService<TDto, TEntity, TRepository, TDBContext> baseAppService) where TDBContext : DbContext where TEntity : Entity, new() where TRepository : BaseDBRepository<TDBContext, TEntity> where TDto : Dto => new LoadPageOffsetModelAuto<TEntity, TDto>();

        public static LoadPageOffsetModelAuto<TEntity, TDto> GetLoadPageOffsetModelAuto<TDto, TEntity, TRepository, TDBContext>(this BaseAppService<TDto, TEntity, TRepository, TDBContext> baseAppService, PagingModel<TDto> pagingQueryModel) where TDBContext : DbContext where TEntity : Entity, new() where TRepository : BaseDBRepository<TDBContext, TEntity> where TDto : Dto
            => Mapper.Map<LoadPageOffsetModelAuto<TEntity, TDto>>(pagingQueryModel);

        public static List<QueryRules> CreateQRList<TDto, TEntity, TRepository, TDBContext>(this BaseAppService<TDto, TEntity, TRepository, TDBContext> baseAppService) where TDBContext : DbContext where TEntity : Entity, new() where TRepository : BaseDBRepository<TDBContext, TEntity> where TDto : Dto
            => new List<QueryRules>();
        #endregion
    }
}
